home *** CD-ROM | disk | FTP | other *** search
/ SGI Freeware 1999 August / SGI Freeware 1999 August.iso / dist / fw_Tix.idb / usr / freeware / lib / tix4.1 / SHList.tcl.z / SHList.tcl
Encoding:
Text File  |  1999-01-26  |  3.8 KB  |  151 lines

  1. # SHList.tcl --
  2. #
  3. #    This file implements Scrolled HList widgets
  4. #
  5. # Copyright (c) 1996, Expert Interface Technologies
  6. #
  7. # See the file "license.terms" for information on usage and redistribution
  8. # of this file, and for a DISCLAIMER OF ALL WARRANTIES.
  9. #
  10.  
  11. tixWidgetClass tixScrolledHList {
  12.     -classname TixScrolledHList
  13.     -superclass tixScrolledWidget
  14.     -method {
  15.     }
  16.     -flag {
  17.      -highlightbackground -highlightcolor -highlightthickness
  18.     }
  19.     -configspec {
  20.     {-highlightbackground -highlightBackground HighlightBackground #d9d9d9}
  21.     {-highlightcolor -highlightColor HighlightColor black}
  22.     {-highlightthickness -highlightThickness HighlightThickness 2}
  23.     }
  24.     -default {
  25.     {.scrollbar            auto}
  26.     {*f1.borderWidth        1}
  27.     {*hlist.Background        #c3c3c3}
  28.     {*hlist.highlightBackground    #d9d9d9}
  29.     {*hlist.relief            sunken}
  30.     {*hlist.takeFocus        1}
  31.     {*Scrollbar.background        #d9d9d9}
  32.     {*Scrollbar.troughColor        #c3c3c3}
  33.     {*Scrollbar.takeFocus        0}
  34.     {*Scrollbar.relief        sunken}
  35.     {*Scrollbar.width        15}
  36.     }
  37.     -forcecall {
  38.     -highlightbackground -highlightcolor -highlightthickness
  39.     }
  40. }
  41.  
  42. proc tixScrolledHList:ConstructWidget {w} {
  43.     upvar #0 $w data
  44.  
  45.     tixChainMethod $w ConstructWidget
  46.  
  47.     set data(pw:f1) \
  48.     [frame $w.f1 -takefocus 0]
  49.     set data(w:hlist) \
  50.     [tixHList $w.f1.hlist -bd 0 -takefocus 1 -highlightthickness 0]
  51.  
  52.     pack $data(w:hlist) -in $data(pw:f1) -expand yes -fill both -padx 0 -pady 0
  53.  
  54.     set data(w:hsb) \
  55.     [scrollbar $w.hsb -orient horizontal -takefocus 0]
  56.     set data(w:vsb) \
  57.     [scrollbar $w.vsb -orient vertical -takefocus 0]
  58.     
  59.     set data(pw:client) $data(pw:f1)
  60. }
  61.  
  62. proc tixScrolledHList:SetBindings {w} {
  63.     upvar #0 $w data
  64.  
  65.     tixChainMethod $w SetBindings
  66.  
  67.     $data(w:hlist) config \
  68.     -xscrollcommand "$data(w:hsb) set"\
  69.     -yscrollcommand "$data(w:vsb) set"\
  70.     -sizecmd "tixScrolledWidget:Configure $w"
  71.  
  72.     $data(w:hsb) config -command "$data(w:hlist) xview"
  73.     $data(w:vsb) config -command "$data(w:hlist) yview"
  74.  
  75. }
  76.  
  77. #----------------------------------------------------------------------
  78. #
  79. #        option configs
  80. #----------------------------------------------------------------------
  81. proc tixScrolledHList:config-takefocus {w value} {
  82.     upvar #0 $w data
  83.   
  84.     $data(w:hlist) config -takefocus $value
  85. }    
  86.  
  87. proc tixScrolledHList:config-highlightbackground {w value} {
  88.     upvar #0 $w data
  89.  
  90.     $data(pw:f1) config -highlightbackground $value
  91. }
  92.  
  93. proc tixScrolledHList:config-highlightcolor {w value} {
  94.     upvar #0 $w data
  95.  
  96.     $data(pw:f1) config -highlightcolor $value
  97. }
  98.  
  99. proc tixScrolledHList:config-highlightthickness {w value} {
  100.     upvar #0 $w data
  101.  
  102.     $data(pw:f1) config -highlightthickness $value
  103. }
  104.  
  105.  
  106. #----------------------------------------------------------------------
  107. #
  108. #        Widget commands
  109. #----------------------------------------------------------------------
  110.  
  111. #----------------------------------------------------------------------
  112. #
  113. #        Private Methods
  114. #----------------------------------------------------------------------
  115. # virtual
  116. #
  117. proc tixScrolledHList:RepackHook {w} {
  118.     upvar #0 $w data
  119.  
  120. if 0 {
  121.     if [tixGetBoolean [$data(w:hlist) cget -header]] {
  122.     set data(vsbPadY) [winfo height $data(w:hlist).tixsw:header]
  123.     } else {
  124.     set data(vsbPadY) 0
  125.     }
  126.  
  127.     puts $data(vsbPadY)\ $data(w:hlist).tixsw:header
  128. }
  129.     tixChainMethod $w RepackHook
  130. }
  131. #----------------------------------------------------------------------
  132. # virtual functions to query the client window's scroll requirement
  133. #----------------------------------------------------------------------
  134. proc tixScrolledHList:GeometryInfo {w mW mH} {
  135.     upvar #0 $w data
  136.  
  137.     set extra [expr [$w.f1 cget -bd]+[$w.f1 cget -highlightthickness]]
  138.  
  139.     set mW [expr $mW - $extra*2]
  140.     set mH [expr $mH - $extra*2]
  141.  
  142.     if {$mW < 1} {
  143.     set mW 1
  144.     }
  145.     if {$mH < 1} {
  146.     set mH 1
  147.     }
  148.  
  149.     return [$data(w:hlist) geometryinfo $mW $mH]
  150. }
  151.